<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>留言板</title>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
	<div class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand hidden-sm" href="" onclick="_hmt.push(['_trackEvent', 'navbar', 'click', 'navbar-首页'])">缘分天空</a>
        </div>
        <div class="navbar-collapse collapse" role="navigation">
          <ul class="nav navbar-nav">
            <li class="hidden-sm hidden-md"><a href="" target="_blank" onclick="_hmt.push(['_trackEvent', 'navbar', 'click', 'v2doc'])">留言板</a></li>
          </ul>
          <!-- 登录开始 -->
          <?php if (isset($_SESSION['nikename'])) { ?>
	          
	          <div class="navbar-right">
					<button type="submit" class="btn btn-default"><?php echo $_SESSION['nikename'] ?></button>
					<a href="./out.php" class="btn btn-success">退出</a>
	            </div>
            <?php }else{ ?>
	            <form class="navbar-form navbar-right" action="./login.php" method="post">
	            <div class="form-group">
	              <input type="text" placeholder="name" class="form-control" name="username">
	            </div>
	            <div class="form-group">
	              <input type="password" placeholder="Password" class="form-control" name="password">
	            </div>
	            <button type="submit" class="btn btn-success">登录</button>
	            <a class="btn btn-success" href="./zhuce.php">注册</a>
	          </form>
            <?php } ?>

          <!-- 登录结束 -->
        </div>
      </div>
    </div>
    <!-- 留言板可能块 -->
    <form action="./liuyan.php" method="post">
	    <div class="col-md-8">
	    	<textarea class="form-control" rows="5" style="margin-top:100px;" name="content"></textarea>
	    </div>
	    <div class="col-md-8" style="margin-top:15px;">
			<div class="input-group">
			    <div class="input-group-addon">用户名</div>
			    <input type="text" class="form-control" id="exampleInputAmount" placeholder="Name" style="width:85%;" name='username'>
			    <button type="submit" class="btn btn-primary" style="float:right; width:10%;">提交</button>
			</div>
	    </div>
    </form>
	<!-- 留言板功能结束 -->
	<div class="col-md-8" style="margin:35px 0px;">
		<div class="progress">
		  <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
		    <span class="sr-only">80% Complete (danger)</span>
		  </div>
		</div>
	</div>
	

	<!-- 留言板内容部分 -->
	<?php foreach ($shujuku as $key => $value) {?>
		<div class="col-md-8 migRow" style="background-color:rgba(255,51,102,0.1);padding-top:25px;font-size:20px;">
			<div class="alert alert-success" role="alert" >
				<span><?php echo $value['username']; ?></span>:
				<span><?php echo $value['content']; ?></span>
				<p style='float:right;margin-left:10px;'>
					<a href="./xiugai.php?id=<?php echo $key; ?>" class="btn btn-default" role="button">修改</a>
					<button liuyanid="<?php echo $key; ?>" class="btn btn-danger delBtn" role="button">删除</button></p>
				<span style='float:right;'><?php echo date("Y-m-d H:i:s",$value['liuyanTime']); ?></span>
			</div>
		</div>
	<?php } ?>

	<script type="text/javascript">
		$(function  () {
			$(".delBtn").click(function(event) {
				var id = $(this).attr('liuyanid');
				var delBtn = $(this);
				$.ajax({
					url: './ajaxdel.php',
					type: 'POST',
					dataType: 'json',
					data: {liuyanid: id},
				})
				.done(function(data) {
					if (data.error==0) {
						delBtn.parents('.migRow').remove();
					};
				})
				.fail(function(data) {
					alert("shibai");
				})
				







			});






		})
	</script>
</body>
</html>